<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>页面跳转</title>
</head>
<!--需求分析:
	页面加载成功5秒后,跳转到黑马官网
技术分析:
	事件: 页面加载事件
    	onload
  定时器:
			setTimeout(函数,时间);
	跳转:
			location.href="路径";-->
<script>
    let count = 5;
    let intervalId;
    onload = function () {
        intervalId = setInterval(countDown, 1000);
    }

    function countDown() {
        count--;
        document.getElementById("secondCount").innerText = count;
        if (count == 0) {
            clearInterval(intervalId);
            location.href = "https://www.baidu.com";
        }
    }
</script>
<body>
<span id="secondCount" style="color: #008f50">5</span>秒后跳转至百度
</body>
</html>